# -*- coding:utf-8 -*-

from src.utils.logger import logger
from src.package_helper.pkg_helper import PkgHelperInterface


class RPMBuild(object):
    _pkg_list = []

    def do_rpmbuild(self):
        for pkg in self._pkg_list:
            try:
                pkg.rpm_build()
            except Exception as err:
                logger.error("fatal to build new package, %s", err)

    def add_build_pkg(self, obj) -> bool:
        if isinstance(obj, PkgHelperInterface) is True:
            self._pkg_list.append(obj)
            return True
        else:
            return False
